﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SevenColorfulTuoDan : System.Web.UI.Page
{

    List<Model.LotteryAnnouncement> lstLotAnnModel = new List<Model.LotteryAnnouncement>();
    List<Model.DoubleBall> lstDBallModel = new List<Model.DoubleBall>();

    #region 遗漏用到的变量   

    //最新一期期数
    string NewQS = "";
    //红球出现的期数
    string RedBllappearQS = "";
    //遗漏期数
    int MissingQS = 0;
    //保存红球和遗漏期数
    string RBorAppearQS = "";
    //保存查到已遗漏数字的个数
    int MissingNumCountRed = 0;
    //篮球遗漏数字的个数
    int MissingNumCountBlue = 0;

    string DoubleBallQS = "";
    string DoubleBallNO = "";

    //分出红球和篮球 
    string[] Ball ;
    string RedBall ;
    string BlueBall ;
    string[] arrRedBall ;

    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
        lstLotAnnModel = Data.LotteryAnnouncement.GetListOrderBy("  LotteryQs desc  ", " LotteryType=7 ");
        if (lstLotAnnModel == null || lstLotAnnModel.Count < 0) return;
        //1-33数字
        for (int k = 1; k < 31; k++)
        {
           
            for (int i = 0; i < lstLotAnnModel.Count; i++)
            {
               // if (MissingNumCountRed == k && k>16) break;
                //if (MissingNumCount >= 33) return;
                if (i == 0)
                {
                    NewQS = lstLotAnnModel[0].LotteryQS;
                }
                DoubleBallQS = lstLotAnnModel[i].LotteryQS;
                DoubleBallNO = lstLotAnnModel[i].LotteryNo;
                //分出红球和篮球 
                Ball = DoubleBallNO.Split('+');
                RedBall = Ball[0];
                BlueBall = Ball[1];
                arrRedBall = Ball[0].Split(',');
                //遍历某期红球
                for (int j = 0; j < arrRedBall.Length; j++)
                {
                    if (MissingNumCountRed == k) break;
                    //红球某个数出现
                    if (k ==Convert.ToInt32(arrRedBall[j]))
                    {
                        MissingNumCountRed++; 
                        //该红球 出现 的 期数
                        RedBllappearQS = lstLotAnnModel[i].LotteryQS;
                        //当前期数-出现的期数=遗漏期数   ，，
                        MissingQS = Convert.ToInt32(NewQS) - Convert.ToInt32(RedBllappearQS);

                        if (MissingNumCountRed == 33)
                        {
                            RBorAppearQS += k + "," + MissingQS;
                        }
                        else
                        {
                            RBorAppearQS += k + "," + MissingQS + "||";
                        }
                        fnMissingQS(0, k, MissingQS);
                        //Response.Write("<script>$("#MissNper"+"++").html("123456")</script>");
                        break;
                        
                    }
                }

                //if (k <= 16)
                //{
                //    if (k != MissingNumCountBlue)
                //    {
                //        if (k == Convert.ToInt32(BlueBall))
                //        {
                //            MissingNumCountBlue++;
                //            MissingQS = Convert.ToInt32(NewQS) - Convert.ToInt32(DoubleBallQS);
                //            fnMissingQS(1, k, MissingQS);
                //        }
                //    }
                //}

            }

        }
        

    }


    public void fnMissingQS(int type,int num,int MissingQS)
    {
        #region  type==0 RedBall
        if (type == 0)
        {
            if (num == 1)
            {
                MissNper1.InnerText = MissingQS.ToString();
            }
            else if (num == 2)
            {
                MissNper2.InnerText = MissingQS.ToString();
            }
            else if (num == 3)
            {
                MissNper3.InnerText = MissingQS.ToString();
            }
            else if (num == 4)
            {
                MissNper4.InnerText = MissingQS.ToString();
            }
            else if (num == 5)
            {
                MissNper5.InnerText = MissingQS.ToString();
            }
            else if (num == 6)
            {
                MissNper6.InnerText = MissingQS.ToString();
            }
            else if (num == 7)
            {
                MissNper7.InnerText = MissingQS.ToString();
            }
            else if (num == 8)
            {
                MissNper8.InnerText = MissingQS.ToString();
            }
            else if (num == 9)
            {
                MissNper9.InnerText = MissingQS.ToString();
            }
            else if (num == 10)
            {
                MissNper10.InnerText = MissingQS.ToString();
            }
            else if (num == 11)
            {
                MissNper11.InnerText = MissingQS.ToString();
            }
            else if (num == 12)
            {
                MissNper12.InnerText = MissingQS.ToString();
            }
            else if (num == 13)
            {
                MissNper13.InnerText = MissingQS.ToString();
            }
            else if (num == 14)
            {
                MissNper14.InnerText = MissingQS.ToString();
            }
            else if (num == 15)
            {
                MissNper15.InnerText = MissingQS.ToString();
            }
            else if (num == 16)
            {
                MissNper16.InnerText = MissingQS.ToString();
            }
            else if (num == 17)
            {
                MissNper17.InnerText = MissingQS.ToString();
            }
            else if (num == 18)
            {
                MissNper18.InnerText = MissingQS.ToString();
            }
            else if (num == 19)
            {
                MissNper19.InnerText = MissingQS.ToString();
            }
            else if (num == 20)
            {
                MissNper20.InnerText = MissingQS.ToString();
            }
            else if (num == 21)
            {
                MissNper21.InnerText = MissingQS.ToString();
            }
            else if (num == 22)
            {
                MissNper22.InnerText = MissingQS.ToString();
            }
            else if (num == 23)
            {
                MissNper23.InnerText = MissingQS.ToString();
            }
            else if (num == 24)
            {
                MissNper24.InnerText = MissingQS.ToString();
            }
            else if (num == 25)
            {
                MissNper25.InnerText = MissingQS.ToString();
            }
            else if (num == 26)
            {
                MissNper26.InnerText = MissingQS.ToString();
            }
            else if (num == 27)
            {
                MissNper27.InnerText = MissingQS.ToString();
            }
            else if (num == 28)
            {
                MissNper28.InnerText = MissingQS.ToString();
            }
            else if (num == 29)
            {
                MissNper29.InnerText = MissingQS.ToString();
            }
            else if (num == 30)
            {
                MissNper30.InnerText = MissingQS.ToString();
            }
            //else if (num == 31)
            //{
            //    MissNper31.InnerText = MissingQS.ToString();
            //}
            //else if (num == 32)
            //{
            //    MissNper32.InnerText = MissingQS.ToString();
            //}
            //else if (num == 33)
            //{
            //    MissNper33.InnerText = MissingQS.ToString();
            //}
        }
        #endregion

        #region  type==1 BuleBall
        //else if (type == 1)
        //{
        //    if (num == 1)
        //    {
        //        MissNperBlue1.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 2)
        //    {
        //        MissNperBlue2.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 3)
        //    {
        //        MissNperBlue3.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 4)
        //    {
        //        MissNperBlue4.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 5)
        //    {
        //        MissNperBlue5.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 6)
        //    {
        //        MissNperBlue6.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 7)
        //    {
        //        MissNperBlue7.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 8)
        //    {
        //        MissNperBlue8.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 9)
        //    {
        //        MissNperBlue9.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 10)
        //    {
        //        MissNperBlue10.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 11)
        //    {
        //        MissNperBlue11.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 12)
        //    {
        //        MissNperBlue12.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 13)
        //    {
        //        MissNperBlue13.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 14)
        //    {
        //        MissNperBlue14.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 15)
        //    {
        //        MissNperBlue15.InnerText = MissingQS.ToString();
        //    }
        //    else if (num == 16)
        //    {
        //        MissNperBlue16.InnerText = MissingQS.ToString();
        //    }
        //}
        #endregion
    }
    

}